from fit_py_ask_number_demo.configs.config import QueryTypeEnum
from fit_py_ask_number_demo.utils import convert_str_to_json


class QuestionClassify:
    def __init__(self, query, key_info):
        self.query = query
        self.key_info = key_info

    def classify_query(self):
        rank_info = self.key_info.get("rank", "")
        comparison_info = self.key_info.get("comparison")
        if rank_info:
            query_type = QueryTypeEnum.rank
        elif comparison_info:
            query_type = QueryTypeEnum.comparison
        else:
            query_type = QueryTypeEnum.simple
        return query_type


def question_classify_impl(query, key_info):
    key_info = convert_str_to_json(key_info)
    return QuestionClassify(query, key_info).classify_query()
